package com.example.login_test.web.servlet; /**
 * @Author: Raymond
 * @Date: 2021/10/21 21:30
 * @Description:
 */

import com.example.login_test.domain.User;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet("/successServlet")
public class SuccessServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
             //获取request域中共享的user对象
        User user = (User) request.getAttribute("user");
        if (user != null) {
            //给页面写一句话
            response.setContentType("text/html;charset=utf-8");
            //输出
            response.getWriter().write("登陆成功，"+user.getUsername()+"欢迎你！");
        }
    }
}
